package com.zl.registration.controller;

import com.zl.registration.entity.ActivityInfo;
import com.zl.registration.module.result.Result;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 活动搜索接口
 *
 * @author zoulei
 * @date 2021/12/7 14:50
 */
@RestController
@RequestMapping("/search")
public class SearchController {
    /**
     * 将活动信息导入ES
     * @return 导入条数
     */
    @PostMapping("/import")
    public Result<Integer> importAll() {
        // TODO 导入功能 返回导入条数

        return Result.success(0);
    }

    /**
     * 根据关键词搜索活动信息
     * @return 满足条件活动列表
     */
    @GetMapping("/simple")
    public Result<List<ActivityInfo>> simpleSearch(@RequestParam String keyWords,
                                                   @RequestParam Integer pageIndex,
                                                   @RequestParam Integer pageSize) {
        // TODO 简单搜索功能

        return Result.success(null);
    }

    @GetMapping("/search")
    public Result<List<ActivityInfo>> search(@RequestParam(required = false) String keyword,
                                             @RequestParam(required = false) Long brandId,
                                             @RequestParam(required = false) Long productCategoryId,
                                             @RequestParam(required = false, defaultValue = "0") Integer pageNum,
                                             @RequestParam(required = false, defaultValue = "5") Integer pageSize,
                                             @RequestParam(required = false, defaultValue = "0") Integer sort) {
        // TODO 综合搜索

        return Result.success(null);
    }

}
